package hl.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;

import com.opensymphony.xwork2.ModelDriven;

import hl.pageModel.DataGrid;
import hl.pageModel.Json;
import hl.pageModel.VenueInfo;
import hl.service.VenueInfoService;

@Namespace("/")
@Action(value = "venueInfoAction")
public class VenueInfoAction extends BaseAction implements ModelDriven<VenueInfo> {

	VenueInfo venueInfo = new VenueInfo();

	private VenueInfoService venueInfoService;

	@Override
	public VenueInfo getModel() {
		return venueInfo;
	}

	public VenueInfoService getVenueInfoService() {
		return venueInfoService;
	}

	public void setVenueInfoService(VenueInfoService venueInfoService) {
		this.venueInfoService = venueInfoService;
	}
	

	public void add() {
		Json j = new Json();
		try {
			venueInfoService.save(venueInfo);
			j.setSuccess(true);
			j.setMsg("增加成功");

		} catch (Exception e) {
			j.setMsg(e.getMessage());
		}
		super.writeJson(j);
	}

	public void getDatagrid() {
		DataGrid d = venueInfoService.getDatagrid(venueInfo);
		super.writeJson(d);
	}
	public void getComboBox() {
		super.writeJson(venueInfoService.getComboBox());
	}
	
	public void edit() {
		Json j = new Json();
		try {
			venueInfoService.edit(venueInfo);
			j.setSuccess(true);
			j.setMsg("修改成功！");

		} catch (Exception e) {
			j.setMsg(e.getMessage());
		}
		super.writeJson(j);
	}

	public void remove() {
		Json j = new Json();
		try {
			venueInfoService.remove(venueInfo);
			j.setSuccess(true);
			j.setMsg("删除成功！");

		} catch (Exception e) {
			j.setMsg(e.getMessage());
		}
		super.writeJson(j);
	}
}
